﻿{include file="public/header" /}
<form method="get">
	<div class="panel admin-panel">
		<div class="panel-head"><strong>{:lang('currency')['list']}</strong></div>
		<div class="padding border-bottom">
			<!-- <script>
            //city 参数和回调
            var pid="{:input('get.pid')}";
            var cid="{:input('get.cid')}";
            var aid="{:input('get.aid')}";
            var selectc=true;
            var selecta=true;
            function select_p(){
                return false;
            }
            function select_c(){
                return false;
            }
            function select_a(){
                location.href="{:url('/admin/order')}?pid="+pid+"&cid="+cid+"&aid="+aid;
            }
            </script>
            {:lang('label')['search']}:
            {:lang('label')['select']}{:lang('currency')['city']}:{include file="public/city" /} -->
			<!--<a type="button" class="button button border-yellow search" href="#" />{:lang('label')['order_id']}{:lang('label')['search']}</a>-->
			订单号：<input class="input input-auto" type="text" name="order_id" value="{:input('get.order_id')}">
			开始日期：<input class="input input-auto" type="text" id="start_date" name="start_date" value="{:input('get.start_date')}">
			结束日期：<input class="input input-auto" type="text" id="stop_date" name="stop_date" value="{:input('get.stop_date')}">
			<button class="button button border-yellow" href="#" />{:lang('label')['search']}</button>
			<a href=""> 取消搜索</a>
		</div>
		<table class="table table-hover">
			<tr>
				<th width="120">{:lang('label')['order_id']}</th>
				<th width="30">{:lang('label')['price']}</th>
				<th width="100">{:lang('label')['name']}</th>
				<th width="100">{:lang('label')['phone']}</th>
				<th width="250">快递单号</th>
				<!--<th width="50">付款</th>-->
				<th width="150">{:lang('label')['time']}</th>
				<th width="180">操作</th>
			</tr>
			{volist name="data" id="order"}
			<tr>
				<td>{$order.order_id}</td>
				<td style="line-height:40px">￥{$order.price}</td>
				<td style="line-height:40px">{$order.name}</td>
				<td style="line-height:40px">{$order.phone}</td>
				<td id="{$order.id}" class="fahuo" style="line-height:40px">{$order.fahuo}</td>
				<!--<td style="line-height:40px">{if $order.ispay == 1}<a class="text-blue ispay" data-id="{$order.id}" href="javascript:;">已付款</a>{else}<a class="text-red ispay" data-id="{$order.id}" href="javascript:;">未付款</a>{/if}</td>-->
				<td style="line-height:40px">{$order.time|date="Y-m-d H:i:s",###}</td>
				<td style="line-height:40px">
					{if $order.status == "1"}
						<a class="button border-red button-little fahuo" id="{$order.id}" href="javascript:;">发货</a>
					{elseif $order.status == "2"}
						<a class="button border-green button-little wancheng" id="{$order.id}" href="javascript:;">完成</a>
					{elseif $order.status == "3"}
						<a class="button border-blue button-little" href="javascript:;">已完成</a>
					{/if}&nbsp;
					<a class="button border-blue button-little" href="javascript:show_detail('__URL__/detail?order_id={$order.order_id}');">{:lang('currency')['detail']}</a>
					<a class="button border-yellow button-little" onclick="if(!confirm('确定要删除吗？'))return false;" href="__URL__/del?id={$order.id}"> 删除</a>
				</td>
			</tr>
			{/volist}
		</table>
		{include file="public/pages" /}
	</div>
</form>
<script src="/web/layui/layui.all.js"></script>
<script>
    layui.laydate.render({
        elem: '#start_date' //指定元素
    });
    layui.laydate.render({
        elem: '#stop_date' //指定元素
    });
    function show_detail(url) {
        layer.open({
            type: 2,
            title:'',
//                    skin: 'layui-layer-rim', //加上边框
            area: ['500px', '600px'], //宽高
            content: url
        });
    }
    $('#select_del').click(function(){
        var str="";
        $("input:checkbox[name=id]:checked").each(function(){
            str+=$(this).val()+",";
        });
        if(str!=''){
            if(confirm("{:lang('currency')['del']}?")){location.href='order/del.html?id='+str;}
        }
    });
    $('.search').click(function(){
        layer.prompt({title:'{:lang('label')['order_id']}{:lang('label')['search']}'},function(val){
            location.href="__ROOT__/admin/order.html?order_id="+val;
        });
    });
    $('.fahuo').click(function(){
        var id = this.id;
        layer.prompt({title:"请输入快递单号"},function(val){
            $.get("__ROOT__/admin/order/fahuo.html?id="+id+"&fahuo="+val,function(data){
                if(data.code == 1){
                    $(this).removeClass("fahuo");
                    $(this).addClass("wancheng");
                    $(this).removeClass("border-red");
                    $(this).addClass("border-green");
                    $(this).html("完成");
                    $("#fahuo_"+order_id).html(val);
                    $("#status_"+order_id).html('<span class="text-sub">配送中</span>');
                    layer.msg(data.msg);
                }else{
                    layer.msg(data.msg);
                }
            })
        });
    });
    $('.ispay').click(function(){
        var mythis = $(this);
        var order_id = mythis.data("id");
        var ispay = mythis.html();
        var is_pay = 1;
        if(ispay == "未付款"){
            ispay = "已付款";
            is_pay = 1;
        }else{
            ispay = "未付款";
            is_pay = 0;
        }
        layer.confirm('修改为'+ispay+'?', {icon: 3, title:'付款状态?'},function(){
            $.get("__ROOT__/admin/order/ispay.html?id="+order_id+"&is_pay="+is_pay,function(data){
                if(data.code == 1){
                    if(mythis.html() == "未付款"){
                        mythis.removeClass("text-red");
                        mythis.addClass("text-blue");
                        mythis.html("已付款");
                    }else{
                        mythis.removeClass("text-blue");
                        mythis.addClass("text-red");
                        mythis.html("未付款");
                    }
                    layer.msg(data.msg);
                }else{
                    layer.msg(data.msg);
                }
            })
        });
    });
    $(document).on('click','.wancheng',function(){
        var id = this.id;
        layer.confirm('请确认货物已送达！', {icon: 3, title:'完成订单?'},function(){
            $.get("__ROOT__/admin/order/wancheng.html?id="+id,function(data){
                if(data.code == 1){
                    mythis.unbind();
                    mythis.removeClass("wancheng");
                    mythis.removeClass("border-green");
                    mythis.addClass("border-blue");
                    mythis.html("已完成");
                    $("#status_"+order_id).html('<span class="text-blue">已完成</span>');
                    layer.msg(data.msg);
                }else{
                    layer.msg(data.msg);
                }
            })
        });
    });
</script>
{include file="public/footer" /}